<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Mobile
 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */
/* @var $this Mage_Sendfriend_Block_Send */
/**
 * Send to friend form
 *
 * @see Mage_Sendfriend_Block_Send
 */
?>
<script type="text/javascript">
/*<![CDATA[*/
    i=0;
    var recipCount  = 1;
    var maxRecip    = <?php echo $this->getMaxRecipients() ?>;
    function remove_recipient(i){
        $('recipients_name'+i).up(2).remove();
        recipCount--;
        if(recipCount<maxRecip && maxRecip != 0) {
            $('add_recipient_button').show();
            $('max_recipient_message').hide();
        }
        return false;
    }

    function add_recipient(){
        ul = $('recipients_options');
        var li_mail = Element.extend(document.createElement("LI"));
        li_mail.addClassName('addElement');
        li_mail.innerHTML = '<div align="right"><a href="delete_email" onclick="remove_recipient('+i+');return false"><img src="<?php echo $this->getSkinUrl('images/list_remove_btn.gif') ?>" alt="<?php echo $this->__('Remove Email') ?>"/><\/a><\/div>'
        li_mail.innerHTML += '<div class="left"><label for="recipients_name"><?php echo $this->__('Name:') ?> <span class="required">*<\/span><\/label><br /><div style="width:250px"><input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name'+i+'" style="width:250px;" /><\/div><br /><br /><\/div>';
        li_mail.innerHTML += '<div class="right"><label for="recipients_email"><?php echo $this->__('Email Address:') ?><span class="required">*<\/span><\/label><br /><div style="width:250px"><input name="recipients[email][]" value="" title="<?php echo $this->__('Email Address') ?>" id="recipients_email'+i+'" type="text" class="input-text required-entry validate-email" style="width:250px;" /><\/div><\/div>';
        i++;
        recipCount++;
        if(recipCount>=maxRecip && maxRecip != 0) {
            $('add_recipient_button').hide();
            $('max_recipient_message').show();
        }

        ul.appendChild(li_mail);
    }
/*]]>*/
</script>

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<div class="page-head">
    <h3><?php echo $this->__('Email to a Friend') ?></h3>
</div>
<form action="<?php echo $this->getSendUrl() ?>" method="post" id="product_sendtofriend_form">
<?php echo $this->getBlockHtml('formkey')?>
<div class="col-1 login-box">
    <div class="col-1 registered-users">
        <div class="content ">
            <div>
                <h4><?php echo $this->__('Sender:') ?></h4>
                 <ul class="form-list" id="sender_options">
                       <li>
                            <div class="left">
                                <label for="sender_name"><?php echo $this->__('Name:') ?> <span class="required">*</span></label><br/>
                                <div style="width:250px"><input name="sender[name]" value="<?php echo $this->htmlEscape($this->getUserName()) ?>" title="<?php echo $this->__('Name') ?>" id="sender_name" type="text" class="input-text required-entry" style="width:250px;" /></div>
                            </div>
                            <div class="right">
                               <label for="sender_email"><?php echo $this->__('Email:') ?> <span class="required">*</span></label><br/>
                               <div style="width:250px"><input name="sender[email]" value="<?php echo $this->htmlEscape($this->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" id="sender_email" type="text" class="input-text required-entry validate-email" style="width:250px;" /></div>
                            </div>
                        </li>
                        <li>
                            <label for="sender_message"><?php echo $this->__('Message:') ?> <span class="required">*</span></label><br/>
                            <textarea name="sender[message]" class="input-text required-entry" id="sender_message" cols="3" rows="3" style="width:100%;height:100px"><?php echo $this->htmlEscape($this->getMessage())?></textarea>
                        </li>

                 </ul>
            </div>

            <div>
                <div>
                   <br />
                   <h4><?php echo $this->__('Recipient:') ?></h4>
                    <ul class="form-list" id="recipients_options">
                            <li>
                                <div class="left">
                                    <label for="recipients_name"><?php echo $this->__('Name:') ?> <span class="required">*</span></label><br/>
                                    <div style="width:250px"><input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name" style="width:250px;" /></div><br /><br />
                                </div>
                                <div class="right">
                                    <label for="recipients_email"><?php echo $this->__('Email Address:') ?> <span class="required">*</span></label><br/>
                                    <div style="width:250px"><input name="recipients[email][]" value="" title="<?php echo $this->__('Email Address') ?>" id="recipients_email" type="text" class="input-text required-entry validate-email" style="width:250px;" /></div>
                                </div>
                            </li>
                    </ul>
                    <div id="max_recipient_message" style="display:none">
                    <?php if ($this->getMaxRecipients()): ?>
                      <?php echo $this->__('Maximum %d email addresses allowed.', $this->getMaxRecipients()) ?>
                    <?php endif; ?>
                    </div>
                    <?php if (1 < $this->getMaxRecipients()): ?>
                        <div id="add_recipient_button">
                            <button class="form-button" onclick="add_recipient();" type="button"><span><?php echo $this->__('Add Recipient') ?></span></button>
                        </div>
                    <?php endif; ?>
               </div>
            </div>
            <div style="clear:both"></div>

        </div>

        <div class="button-set">
            <button class="form-button right<?php if (!$this->canSend()):?> disabled<?php endif ?>" type="submit"<?php if (!$this->canSend()):?> disabled="disabled"<?php endif ?>><span><?php echo $this->__('Send email') ?></span></button>
        </div>
    </div>
</div>
</form>
<script type="text/javascript">
    var productSendtofriendForm = new VarienForm('product_sendtofriend_form');
    productSendtofriendForm.submit = function() {
        if(this.validator.validate()) {
            this.form.submit();
        }
    }.bind(productSendtofriendForm);
</script>
